<template>
    <view class="wrapInfo">
        <view v-for="(item,idx) in consult" :key="idx" style="margin-top: 30rpx;">
            <view class="time consultContent">{{ item.createTime }}</view>
            <view class="consult"  @click="getDetail">
                <view class="consultTitle">{{ item.title }}</view>
                <view class="consultContent">{{ item.content }}</view>
            </view>
        </view>
    </view>
</template>

<script>
import {getConsultInfo} from '../../../utils/api'
    export default {
        data(){
            return{
                id:'',
                type:'',
                pageNo:1,
                continue: true,
                consult:[],
            }
        },
        onLoad(options){
            console.log("咨询消息option",options)
            this.id = options.userid
            this.type = options.type
            this.initData()
        },
        methods: {
            async initData(){
                const res = await getConsultInfo(this.id,this.pageNo,10,this.type == 'sys' ? '系统消息':'咨询消息');
                if(this.continue){
                    if(res.result.records.length < 10){
                        this.continue = false;
                        this.consult = [...this.consult,...res.result.records]
                    }else{
                        this.consult = [...this.consult,...res.result.records]
                    }
                }
                
                console.log("详情res",res)
            }
        },
        onReachBottom(){
            if(this.continue){
                this.pageNo++
                this.initData();
            }
        },
        onHide(){
            this.continue = false
        }
        
    }
</script>

<style lang="scss" scoped>
.time{
    text-align: center;
    color: #737B80;
    font-size: 12px;
    margin-top: 10rpx;
}
.consult{
	padding: 30rpx;
	background-color: #fff;
	border-radius: 10rpx;
	.consultTitle{
		color: #121212;
	}
	.consultContent{
		color: #737B80;
		font-size: 12px;
		margin-top: 10rpx;
	}
}
.wrapInfo{
    padding: 30rpx;
}

</style>
<style>
page{
    background-color: #F5F5F5;
}
</style>